<script lang="tsx">
import useRender from "@/utils/hooks/render";
import { Input } from "@tarojs/components";

export default {
  props: {
    fieldValue: String,
  },
  setup(props, ctx) {
    useRender(() => (
      <div class="text-field">
        <Input
          max-length="100"
          type="text"
          {...(ctx.attrs || {})}
          value={props.fieldValue}
          onInput={(e) => {
            ctx.emit("field-change", e.detail.value);
            return e.detail.value;
          }}
        />
        {/* <nut-input
    max-length="100"
    clearable
    {...(ctx.attrs || {})}
    //    onBlur={(e) => {
    //     ctx.emit("field-change", e.detail.value);
    //   }}
    // 好像onChange也会
    //    onChange={(e) => {
    //      ctx.emit("field-change", e.detail.value);
    //   }}
    //这里不适用update:model-value（失去焦点也会触发，值为空字符串）
    //model-value={value.value}
    onUpdate:model-value={(e) => {
      ctx.emit("field-change", e);
    }}
  ></nut-input> */}
      </div>
    ));
    return {};
  },
};
</script>

<style lang="scss" module></style>
